package per.chenyl.framework.persistence.common.util;

import java.util.Collection;
import java.util.Objects;

public class CommonUtil {
    public static String getNonNullString(Object o) {
        return Objects.isNull(o) ? "" : String.valueOf(o);
    }

    public static boolean isNotEmptyCollection(Collection c) {
        return Objects.nonNull(c) && !c.isEmpty();
    }

    public static boolean isNotEmptyArray(Object[] array) {
        return Objects.nonNull(array) && array.length > 0;
    }

    public static <T> T[] requireNonEmptyArray(T[] array) {
        if (array == null || array.length < 1) {
            throw new RuntimeException("数组不可为空！");
        }
        return array;
    }
}
